#lang sicp

(define (multiply a b)
  (define (iter a b ans)
    (cond ((= b 0) ans)
          ((odd? b) (iter (double a) (halve b) (+ ans a)))
          (else (iter (double a) (halve b) ans))))
          
  (iter a b 0))